[

    async function( kuo,Context,context){
        Context.headers["content-type"] = 'application/json; charset=UTF-8';
        let LANG = this.LANG();
        let $DATA = Object.assign({},this.$DATA);
        let $Security = await Mem.Get("session/"+kuo.sessionid);
        if(! $Security ){
            $Security ={ adminid: 0};
        }
        if(typeof($Security['adminid']) == "undefined" ){
            $Security['adminid'] = 0;
        }
        if($Security['adminid'] < 1){
            $DATA.code = 99;
            $DATA.msg = "Go Login";
            Context.body =JSON.stringify($DATA);
            return ;
        }
        let fan = await Mode("admin").Loginok(kuo,$Security);
        if(fan){
            $DATA.code = fan;
            $DATA.msg = "Error";
            if($Security['adminid'] > 0){
                let $hash = 'safetoken/'+$Security['adminid'];
                $DATA.token = Mode("Tools").Uuid();
                Mem.Set($hash,$DATA.token);
            }
            Context.body = JSON.stringify($DATA);
            return ;
        }

        kuo.adminid = $Security['adminid'];
        let $hash = 'safetoken/'+kuo.adminid;
        $DATA.token = Mode("Tools").Uuid();
        Mem.Set($hash,$DATA.token);
        let  $kongzhi = kuo.Path[1]?kuo.Path[1]:"get";

        let  $db = await db('cms_content');
        let  $_GET = kuo.get;
        let  $_POST = kuo.post;
        let  $chushi = true; 
        let  $features = await Kuoplus(kuo.class);
        
        if($kongzhi == 'get'){
            let $where ={};
            let $leixing =  Mode("Tools").Int(kuo.Path[2]?kuo.Path[2]:0);
            let $page = Mode("Tools").Int($_GET['page']?$_GET['page']:1);
            let $limitx  =  Mode("Tools").Int($_GET['limit']?$_GET['limit']:10);
            if($limitx < 10 ){
                $limitx = 10;
            }else if($limitx > 100 ){
                $limitx = 100;
            }
            if($leixing > 0){
                $where['subclass IN'] =  await this.TYPE_BAOHAN($leixing);
            }
            if(isset($_GET['type']) && $_GET['type'] != ""){
                $chushi = false; 
                $where['off'] = Mode("Tools").Int($_GET['type']);
            }
            if(isset($_GET['uid']) && $_GET['uid'] != ""){
                $chushi = false; 
                $where['uid'] = Mode("Tools").Int($_GET['uid']);
            }
            if(isset($_GET['name']) && $_GET['name'] != ""){
                if($where['subclass IN']){
                    delete($where['subclass IN']);
                }

                $chushi = false; 
                $where['('] = "and";
    
                $where['name LIKE'] = "%"+$_GET['name']+"%";
                $where['keywords OLK'] = "%"+$_GET['name']+"%";
                $where['describes OLK'] = "%"+$_GET['name']+"%";
                $where['remarks OLK'] = "%"+$_GET['name']+"%";
                $where['id OR'] = $_GET['name'];
                $where[')'] = "";
            }
        
            
            if(isset($_GET['atimestart']) && $_GET['atimestart'] != ""){
                $chushi = false; 
                $where['atime >'] =strtotime($_GET['atimestart']);
            }
            if(isset($_GET['atimeend']) && $_GET['atimeend'] != ""){
                $chushi = false; 
                $where['atime <'] =strtotime($_GET['atimeend']);
            }
          
           
            let $data  = await $db.Where($where).Limit($limitx,$page).Order("id desc").Select();
           
            let $total = await $db.Where($where).Total();
            if(!$data){
                $data= [];
            }
            $DATA.code = 0;
            $DATA.count = $total;
            if($page == 1 && $chushi){
                $DATA.ALLTYPE = await this.ADMIN_TYPELIST(0);
                if($DATA.ALLTYPE ){
                    $DATA.ALLTYPE.unshift({ 'title':"全部分类",'id':0});
                }else{
                    $DATA.ALLTYPE  =[{ 'title':"全部分类",'id':0}];
                }

                $DATA['内容模版'] ={'':'默认内容neirog'};
                if( isset($features['configure']['内容模版'])){
                    for(var xxx in $features['configure']['内容模版']){
                        let $vv = $features['configure']['内容模版'][xxx];
                        $DATA['内容模版'][$vv] = $vv;
                    }
                }
            }

            $DATA.data = $data;
    
        }else if($kongzhi == 'put'){

            $_POST['name'] = Mode("Tools").Xss($_POST['name']?$_POST['name']:"");
            if($_POST['name'] == ""){
                $DATA.code = -1;
                $DATA.msg = LANG.name_kong;
                Context.body = JSON.stringify($DATA);
                return ;
            }
            let $id = Mode("Tools").Int($_POST['id']?$_POST['id']:0);
            let $data = await $db.Where({id: $id}).Find();
            if(!$data){
                $DATA.code = -1;
                $DATA.msg = LANG.get_no;
                Context.body = JSON.stringify($DATA);
                return ;
            }
            $_POST['xtime'] = Mode("Tools").Time();
            if($_POST['url'] != $data['url'] || $_POST['url'] == ""){
                if($data['url'] != ""){
                   await $db.Where({id: $id}).Update({'url':''});
                }
                let $fanx = await this.ADMIN_FINDURL($_POST['url']);
                if(!$fanx){
                    $_POST['url'] = ($features['configure']['默认前缀']['1']?$features['configure']['默认前缀']['1']: "" )+$id;
                    $fanx = await this.ADMIN_FINDURL($_POST['url']);
                    if(!$fanx){
                        $_POST['url']  = 'content_'+$id;
                    }
                }
            }
            if($Security['groups'] > 0){
                $_POST['adminuid'] = kuo.adminid;
            }

            $_POST['keywords']= implode(',',$_POST['keywords']);
            $_POST['expansion'] = await this.ExpAnSion($_POST);

            let $fan = await $db.Where({id: $id}).Update($_POST);
            if($fan){
             

                if(Kuo_pointsmall && Kuo_pointsmall.shopsku_Up ){
                    Kuo_pointsmall.shopsku_Up($_POST,'put');
                }

                await Kuolog('adminlog',kuo.adminid,3,{'yuan':$data,'data':$_POST},kuo.func_,kuo.class,kuo.ip);
                $DATA.data = $_POST;
                $DATA.code =1;
                $DATA.msg = LANG.put_ok;
            }else{
                $DATA.code =-1;
                $DATA.msg = LANG.put_no;
            }   
            
            await this.KUO_Call("Put",$data['subclass'],$id,kuo.adminid,$DATA.token,$_POST);

        }else if($kongzhi == 'add'){
    
            $_POST['name'] = Mode("Tools").Xss($_POST['name']?$_POST['name']:"");
            if($_POST['name'] == ""){
                $DATA.code = -1;
                $DATA.msg = LANG.name_kong;
                Context.body = JSON.stringify($DATA);
                return ;
            }

             $_POST['atime'] = $_POST['xtime'] = Mode("Tools").Time();

             let $gengurl = false;
             if($_POST['url'] == "" ){
                 $gengurl = true;
             }else {
                 let $fanx = await this.ADMIN_FINDURL($_POST['url']);
                 if(!$fanx){
                     $gengurl = true;
                 }
             }


            if($Security['groups'] > 0){
                $_POST['adminuid'] = kuo.adminid;
            }

            $_POST['keywords']= implode(',',$_POST['keywords']);
            $_POST['expansion'] = await this.ExpAnSion($_POST);

            let $fan =await $db.Insert($_POST);
            if($fan){
                $DATA.code = 1;
                $DATA.msg = LANG.add_ok;
                if( $gengurl){
                    $_POST['url'] = ($features['configure']['默认前缀']['1']?$features['configure']['默认前缀']['1']: "" )+$fan;
                    let $fanx = await this.ADMIN_FINDURL( $_POST['url'] );
                    if(!$fanx){
                        $_POST['url']  = 'content_'+$fan;
                    }
                    await $db.Where({'id':$fan}).Update( {'url' :$_POST['url']});
                }

                if(Kuo_pointsmall && Kuo_pointsmall.shopsku_Up ){
                    $_POST.id = $fan;
                    Kuo_pointsmall.shopsku_Up($_POST,'add');
                }
               

                await Kuolog('adminlog',kuo.adminid,4, $_POST ,kuo.func_,kuo.class,kuo.ip);
            }else{
                $DATA.code = -1;
                $DATA.msg = LANG.add_no;
            }
          
            await this.KUO_Call("Add",$_POST['subclass'],$fan,kuo.adminid,$DATA.token,$_POST);
           
    
    
        }else if($kongzhi == 'del'){
            
            if(isset($_POST['expansion'])){
                var $FANHUI = {};
                let $fenlei  = $_POST['expansion'];
                $FANHUI['expansion'] =  await this.ADMIN_expansionform($fenlei);
                let $id_ =  $_POST['Expandid'];
                $FANHUI['Expand'] = {};
                if($fenlei > 0 ){
                    let $KUOFENLEI = await this.TYPE_find({'id':$fenlei});
                    if($KUOFENLEI){
                        if( $KUOFENLEI['Expand'] && $KUOFENLEI['Expand'] != ""){
                            let $chanfende = explode(',',$KUOFENLEI['Expand']);
                            if($chanfende){
                                for(let expand_ in $chanfende ){
                                    let $expand = Trim($chanfende[expand_]);
                                    if($expand != ""){
                                        let $expand_ = explode('_',$expand);
                                        if( count( $expand_ ) > 1){
                                            let $class_ = $expand_['0'];
                                            delete($expand_['0']);
                                            let $expandPOST = {};
                                            $expandPOST['id'] = $id_;
                                            $expandPOST['Safe_AdminId'] = kuo.adminid;
                                            $expandPOST['Safe_Token']  = $DATA.token;
                                            $FANHUI['Expand'][$expand] = [];
                                            let hanshu = implode('_',$expand_)+'_Get';

                                          

                                            if(global["Kuo_"+$class_] && global["Kuo_"+$class_][hanshu]){
                                                
                                                $FANHUI['Expand'][$expand] = await global["Kuo_"+$class_][hanshu]($expandPOST);
                                            }
                                            if(!is_array($FANHUI['Expand'][$expand])){
                                                $FANHUI['Expand'][$expand] = [];  
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
              
                $DATA.code = 1;
                $DATA.data = $FANHUI;
                $DATA.msg = "ok";

                if($_POST['isshop']  &&  $_POST['isshop'] == 1 ){

                    if(Kuo_pointsmall && Kuo_pointsmall.shopsku_Up ){
                        $DATA.data.SHOP = await  Kuo_pointsmall.shopsku_Get($id_);
                    }
                    
                }


                Context.body = JSON.stringify($DATA);
                return ;
            }

            let $id = Mode("Tools").Int($_POST['id']?$_POST['id']:0);
            let $data = await $db.Where({id: $id}).Find();
            if(!$data){
                $DATA.code = -1;
                $DATA.msg = LANG.admin_id_no;
                Context.body = JSON.stringify($DATA);
                return ;
            }
            let $fan = await $db.Where({id: $id}).Delete();
            if($fan){
                await Kuolog('adminlog',kuo.adminid,5, $data ,kuo.func_,kuo.class,kuo.ip);
                await this.KUO_Call("Del",$data['subclass'],$id,kuo.adminid,$DATA.token,$_POST);
                $DATA.code = 1;
                $DATA.msg = LANG.del_ok;
            }else{
                $DATA.code = -1;
                $DATA.msg = LANG.del_no;
            }
        }
        Context.body = json_encode($DATA);
    }

]